{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "66ef5578",
   "metadata": {},
   "source": [
    "----------\n",
    "* 日期：2022-09-07\\week03\n",
    "* 课程：python\n",
    "* 记录人：zhoubilian"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d5c3299",
   "metadata": {},
   "source": [
    "\n",
    "-----------\n",
    "\n",
    "# 本周学习内容\n",
    "\n",
    "> 1.变量\n",
    ">> 1.变量的定义与声明\n",
    ">>> 变量用于储存要在计算机程序中引用和操作的信息\n",
    "\n",
    ">> 2.变量名的一般规则\n",
    ">>> * 变量名只能是字母、数字或下划线的任意组合\n",
    ">>> * 变量名的第一个字母不能是数字\n",
    "\n",
    "\n",
    "> 2.编程的控制流\n",
    ">> 1.条件判断\n",
    ">> 2.循环遍历\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34ffd390",
   "metadata": {},
   "source": [
    "## 1.变量学习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "312c6bb4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2200000001\n"
     ]
    }
   ],
   "source": [
    "## 变量学习\n",
    "网三_01_ID=\"2200000001\"\n",
    "print(网三_01_ID)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1adb7919",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网三_01_ID\n"
     ]
    }
   ],
   "source": [
    "print('网三_01_ID')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "626857f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小白 小白\n",
      "Alex 小白\n"
     ]
    }
   ],
   "source": [
    "网三_01_name=\"小白\"\n",
    "\n",
    "网三_02_name=网三_01_name\n",
    "\n",
    "print(网三_01_name,网三_02_name)\n",
    "\n",
    "网三_01_name=\"Alex\"\n",
    "\n",
    "print(网三_01_name,网三_02_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "04b0c92d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2708299318960"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网三_01_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b1a3f152",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2708299226736"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网三_02_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "435b694f",
   "metadata": {},
   "source": [
    "## 2.条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31bba5a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "#课本案例 P18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "029d19ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Recover,then rest.\n"
     ]
    }
   ],
   "source": [
    "#变量today需要先赋值\n",
    "today=\"Sunday\"\n",
    "condition=\"Headache\"\n",
    "\n",
    "\n",
    "if today==\"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today==\"Sunday\":\n",
    "    if condition==\"Headache\":\n",
    "        print(\"Recover,then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work,Work.Work.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "810229f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "#练习题：判断今天是否有Python课（time.localtime()）,然后如果今天有Pytihon课，再判断现在是否是Python课ing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b8688245",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=7, tm_hour=20, tm_min=7, tm_sec=30, tm_wday=2, tm_yday=250, tm_isdst=0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "19b5e644",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "20\n",
      "37\n",
      "今天有Python课\n",
      "Python课ing，现在在第三节课\n"
     ]
    }
   ],
   "source": [
    "# 创建week_day变量,time_hour变量，time_min变量\n",
    "week_day = time.localtime().tm_wday\n",
    "print(week_day)\n",
    "\n",
    "time_hour=time.localtime().tm_hour\n",
    "print(time_hour)\n",
    "\n",
    "time_min=time.localtime().tm_min\n",
    "print(time_min)\n",
    "\n",
    "if week_day==2:\n",
    "    print(\"今天有Python课\")\n",
    "    if time_hour ==19:\n",
    "        print(\"Python课ing，刚上课\")\n",
    "    elif time_hour==18 and time_min > 44:\n",
    "         print(\"Python课ing，现在在第二节课\")\n",
    "    elif time_hour==20 and time_min < 51:\n",
    "        print(\"Python课ing，现在在第三节课\")\n",
    "    elif time_hour < 18:\n",
    "         print(\"期待今天的课\")\n",
    "    else:\n",
    "         print(\"今天的Python课很不错\")\n",
    "else:\n",
    "    print(\"怎么还没到周三，哎，等得有点着急\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60ebc7b6",
   "metadata": {},
   "source": [
    "##  3.循环遍历\n",
    "\n",
    "> 1.for循环\n",
    "\n",
    "> 2.range()方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "83487dc3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# 用例1\n",
    "for i in[1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ad48fa2b",
   "metadata": {},
   "outputs": [],
   "source": [
    "#用例2\n",
    "for ch in \"Hi!\":\n",
    "    print(ch)\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2b7f2c5",
   "metadata": {},
   "source": [
    "## 4.关于强大的range()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "f814057a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range 可以创建数组\n",
    "#用例3 默认从0开始的（star），5是终点，默认步长为1\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "4ae0300e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展1:起点为1 （可以设置起点）\n",
    "for num in range(1,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "89315a0e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展2:起点为1  终点为10 步长（step）2\n",
    "for num in range(1,10,2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "68fb1db2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "8\n",
      "6\n",
      "4\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展3\n",
    "for num in range(10,1,-2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c88f75c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
